草庐IT

python - PIP 安装和 Python 路径

全部标签

ruby - 如何在 ruby​​ 中做一个安全的连接路径名?

我的Rails开发环境是基于Windows的,我的生产环境是基于Linux的。可能会使用VirtualHost。假设需要在/public文件夹中使用File.open('/tmp/abc.txt','r')引用一个文件名。——但在Windows中它应该是C:\tmp\abc.txt。如何进行正确的路径连接以处理两种不同的环境?prefix_tmp_path='/tmp/'filename="/#{rand(10)}.txt"fullname=prefix_tmp_path+filename#/tmp//1.txt当prefix_tmp_path="C:\tmp\"我得到C:\tmp\/

ruby - 使用 RVM 安装 Ruby 1.9.3 但命令行不显示 ruby​​ -v

这是控制台输出:sergio@sergio-VirtualBox:~$rvmlistrvmrubiesruby-1.9.3[i386]sergio@sergio-VirtualBox:~$rvmuse1.9.3Using/usr/share/ruby-rvm/gems/ruby-1.9.3sergio@sergio-VirtualBox:~$ruby-vTheprogram'ruby'canbefoundinthefollowingpackages:*ruby1.8*ruby1.9.1Try:sudoapt-getinstall这是怎么回事?我需要重启我的机器吗?或者它应该立即起作用吗

ruby - 安装 CocoaPods : no response

尝试从终端安装CocoaPods:$sudogeminstallcocoapods输入根密码后,没有任何反应。我该如何调试它? 最佳答案 对于其他有同样疑问的人,安装gem需要很长时间。如果你运行:exportGEM_HOME=~/.gemsexportPATH=$GEM_HOME/bin:$PATHgeminstallcocoapods-V使用标记V进行安装会启用详细的输出,这样您就可以在下载和安装过程中看到所有输出,非常多。 关于ruby-安装CocoaPods:noresponse

ruby - 无法在 OS X "El Capitan"上安装 gems

我无法在ElCapitanBeta5上安装和运行fakes3gem。我试过:sudogeminstallfakes3ERROR:Whileexecutinggem...(Errno::EPERM)Operationnotpermitted-/usr/bin/fakes3然后我尝试用cocoapods的方式来做。它适用于cocoapods但不适用于fakes3。mkdir-p$HOME/Software/rubyexportGEM_HOME=$HOME/Software/rubygeminstallcocoapods[...]1geminstalledgeminstallfakes3ER

ruby-on-rails - 无法安装 pg gem

我尝试使用geminstallpg但它似乎不起作用。geminstallpg给出这个错误TemporarilyenhancingPATHtoincludeDevKit...Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingpg:ERROR:Failedtobuildgemnativeextension.C:/Ruby/bin/ruby.exeextconf.rbcheckingforpg_config...noNopg_config...tryinganyway.Ifbuildingfails,ple

ruby - 如何从Ruby中的文件路径获取不带扩展名的文件名

如何从Ruby中的文件路径获取文件名?例如,如果我的路径是"C:\projects\blah.dll"而我只想要“blah”。Ruby中有LastIndexOf方法吗? 最佳答案 尝试File.basenameReturnsthelastcomponentofthefilenamegiveninfile_name,whichmustbeformedusingforwardslashes(``/’’)regardlessoftheseparatorusedonthelocalfilesystem.Ifsuffixisgivenandp

ruby - rvm 安装不工作 : "RVM is not a function"

我刚刚安装了RVM,但无法正常工作。我的.profile文件末尾有这样一行:[[-s"$HOME/.rvm/scripts/rvm"]]&&."$HOME/.rvm/scripts/rvm"我尝试运行source.profile并重新启动终端,但是,当我运行rvmuse1.9.2时,我仍然得到:RVMisnotafunction,selectingrubieswith'rvmuse...'willnotwork.我的系统是Ubuntu11.10。 最佳答案 您需要运行以下命令$source~/.rvm/scripts/rvm然后运行

ruby - 如何找到gem文件的安装位置

我可以找到使用gemlist安装的gem,但它没有显示这些gem的安装位置。如何找到gem的位置,以及在安装gem之前我如何知道它将被安装到哪里? 最佳答案 使用gemenvironment了解您的gem环境:RubyGemsEnvironment:-RUBYGEMSVERSION:2.1.5-RUBYVERSION:2.0.0(2013-06-27patchlevel247)[x86_64-darwin12.4.0]-INSTALLATIONDIRECTORY:/Users/ttm/.rbenv/versions/2.0.0-p2

ruby - 如何在 Ruby 中获取当前工作目录的绝对路径?

我在Windows上运行Ruby,但我不知道这是否会有所不同。我只想获取当前工作目录的绝对路径。这可能来自irb吗?显然,从脚本中可以使用File.expand_path(__FILE__)但是我从irb尝试了以下操作并得到了“权限被拒绝”错误:File.new(Dir.new(".").path).expand 最佳答案 Dir.pwd为当前工作目录http://ruby-doc.org/core/Dir.html#method-c-pwd 关于ruby-如何在Ruby中获取当前工作目

ruby - 无法构建 gem native 扩展(安装 Compass)

当我尝试安装最新版本的compass(https://rubygems.org/gems/compass/versions/1.0.0.alpha.17)时,出现以下错误。ERROR:Errorinstallingcompass:ERROR:Failedtobuildgemnativeextension.ERROR:Errorinstallingcompass:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.r